package com.gzz.service.impl;

import com.gzz.Dto.TicketOrderDto;
import com.gzz.pojo.BookPerson;
import com.gzz.pojo.PlayerPerson;
import com.gzz.pojo.TicketOrder;
import com.gzz.pojo.TikcetOrderDetail;
import com.gzz.mapper.TikcetOrderDetailMapper;
import com.gzz.service.TikcetOrderDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 周佳成
 * @since 2023-11-24
 */
@Service
public class TikcetOrderDetailServiceImpl extends ServiceImpl<TikcetOrderDetailMapper, TikcetOrderDetail> implements TikcetOrderDetailService {

	@Override
	public List<TikcetOrderDetail> getListByDto(TicketOrderDto ticketOrderDto, TicketOrder ticketOrder) {
		BookPerson bookPerson = ticketOrderDto.getBookPerson();
		Long bookId = bookPerson.getId();
		List<PlayerPerson> list = ticketOrderDto.getPlayerPerson();
		Long OrderId = ticketOrder.getOrderId();
		List<TikcetOrderDetail> resList = new ArrayList<>();
		BigDecimal pr = ticketOrderDto.getPrice();


		for(PlayerPerson playerPerson:list){
			TikcetOrderDetail tikcetOrderDetail1 = new TikcetOrderDetail();
			tikcetOrderDetail1.setOrderId(OrderId);
			tikcetOrderDetail1.setBookId(bookId);
			tikcetOrderDetail1.setPrice(pr);
			tikcetOrderDetail1.setCreateTime(new Date());
			tikcetOrderDetail1.setTypeId(ticketOrderDto.getTypeId());
			tikcetOrderDetail1.setPalyerId(playerPerson.getId());
			resList.add(tikcetOrderDetail1);
		}



		return  resList;
	}
}
